<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <script src="react-demos/build/react.development.js"></script>
        <script src="react-demos/build/react-dom.development.js"></script>
        <script src="react-demos/build/babel.min.js"></script>
        <script src="react-demos/build/jquery.min.js"></script>
    </head>
    <body>
        <div id="example"></div>
        <script type="text/babel">
        class UserGist extends React.Component {
            constructor(props) {
                super(props)
                this.state = {
                    username: '',
                    lastGistUrl: ''
                }
            }
            componentDidMount() {
                $.get(this.props.source, function(result) {
                    var lastGist = result[0];
                    this.setState({
                    username: lastGist.owner.login,
                    lastGistUrl: lastGist.html_url
                    });
                }.bind(this));
            }
            render() {
                return (
                    <div>
                    {this.state.username}'s last gist is <a href={this.state.lastGistUrl}>here</a>.
                    </div>
                );
            }
        }
        ReactDOM.render(
            <UserGist source="https://api.github.com/users/octocat/gists" />,
            document.getElementById('example')
        );
        </script>
      </body>
</html>